package com.jiayinlending.jiayindai.fragment;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;

import com.jiayinlending.jiayindai.R;
import com.jiayinlending.jiayindai.activity.loan.PerfectLoanMessegeActivity;

import butterknife.ButterKnife;

/**
 * Created by xiaohei on 2017/3/28.
 */

public class LoanFragment extends Fragment {
    Toolbar toolbar;
    private View mRootView;
    private Button bt_begin;
    private SeekBar sb_loan_jindu;

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (mRootView != null) {
            return mRootView;
        } else {
            mRootView = inflater.inflate(R.layout.fragment_loan, container, false);
            ViewGroup parent = (ViewGroup) mRootView.getParent();
            if (parent != null) {
                parent.removeView(mRootView);
            }
            bt_begin = (Button) mRootView.findViewById(R.id.bt_begin);
            bt_begin.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
//                    Intent intent = new Intent(LoanFragment.this, PerfectLoanMessegeActivity.class);
//                    startActivity(intent);
                    startActivity(new Intent(getContext(), PerfectLoanMessegeActivity.class));
                }
            });
            sb_loan_jindu = (SeekBar) mRootView.findViewById(R.id.sb_loan_jindu);
            sb_loan_jindu.setMax(50000);
            sb_loan_jindu.setProgress(30000);
            TextView toolbar_title  = (TextView) mRootView.findViewById(R.id.toolbar_title);
            TextView toolbar_subtitle = (TextView) mRootView.findViewById(R.id.toolbar_subtitle);
            toolbar_subtitle.setText("");
            toolbar_subtitle.setBackground(getResources().getDrawable(R.mipmap.message));
            toolbar_title.setText("我要借款");
            return mRootView;
        }
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

}
